- name: put infra repos into yum.repos.d
  copy: src=files/dnf/{{ ansible_architecture }}/{{ item }} dest=/etc/yum.repos.d
  with_items:
    - infra-tags.repo

- name: disable updates-testing
  shell: rm -f /etc/yum.repos.d/fedora-updates-testing.repo

- shell: dnf -y upgrade
  when: prepare_base_image is defined

- name: set bigger timeout for yum
  ini_file: dest=/etc/yum.conf section=main option=timeout value=1000

- name: set bigger timeout for dnf
  ini_file: dest=/etc/dnf/dnf.conf section=main option=timeout value=1000

- name: install pkgs
  dnf: state=present pkg={{ item }}
  with_items:
    - dnf
    - dnf-plugins-core
    - mock
    - createrepo_c
    - yum-utils
    - pyliblzma
    - rsync
    - openssh-clients
    - libselinux-python
    - libsemanage-python
    - yum
    - scl-utils-build
    - ethtool
    - nosync
    - expect

- name: disable @copr/copr explicitly
  shell: dnf copr -y disable @copr/copr

- name: make sure newest rpm
  dnf: state=latest pkg={{ item }}
  with_items:
    - rpm
    - glib2
    - ca-certificates
    - mock
    - dnf
    - copr-rpmbuild
    - rpkg

- name: put updated mock configs into /etc/mock
  template: src=files/mock/{{ item }} dest=/etc/mock
  with_items:
    - site-defaults.cfg
    - fedora-26-ppc64le.cfg
    - fedora-27-ppc64le.cfg
    - fedora-27-i386.cfg
    - fedora-27-x86_64.cfg

- name: put copr-rpmbuild configuration file in the right place
  copy: src=files/main.ini dest=/etc/copr-rpmbuild/main.ini

- name: mockbuilder user
  user: name=mockbuilder groups=mock

- name: mockbuilder .ssh
  file: state=directory path=/home/mockbuilder/.ssh mode=0700 owner=mockbuilder group=mockbuilder

- name: mockbuilder authorized_keys
  authorized_key: user=mockbuilder key='{{ lookup('file', '/home/copr/provision/files/buildsys.pub') }}'

- name: root authorized_keys
  authorized_key: user=root key='{{ lookup('file', '/home/copr/provision/files/buildsys.pub') }}'

- lineinfile: dest=/etc/security/limits.conf line="* soft nofile 10240" insertafter=EOF
- lineinfile: dest=/etc/security/limits.conf line="* hard nofile 10240" insertafter=EOF

- name: disable core dumps
  ini_file: dest=/etc/systemd/coredump.conf section=Coredump option=Storage value=none

- name: 'Remove %_install_langs from /etc/rpm/macros.image-language-conf'
  lineinfile:
    dest: '/etc/rpm/macros.image-language-conf'
    regexp: '^%_install_lang.*'
    state: 'absent'
